<template>
	<view>
		<u-navbar title="我的" :is-back="false" titleColor="#fff" :background="background"></u-navbar>
		<view class="u-flex user-box u-p-30">
			<view class="u-m-r-10">
				<u-avatar :src="'../../static/headimage/'+imgAddress+'.jpg'" size="140" @click="goSelectheadpic()"></u-avatar>
			</view>
			<view class="u-flex-1">
				<view class="u-font-18 u-p-b-20">{{name}}</view>
				<view class="u-font-14 u-tips-color">{{stuNumber}}</view>
			</view>
			<!-- <view class="u-m-l-10 u-p-10">
				<u-icon name="scan" color="#969799" size="28" @click="scan()"></u-icon>
			</view> -->
			<view class="u-m-l-10" @click="denglu()">
				<u-icon name="arrow-right" color="#969799" size="28"></u-icon>
			</view>
		</view>

		<view class="u-m-t-20">
			<u-cell-group>
				<!-- <u-cell-item icon="calendar" :iconStyle="iconStyle" title="签到" @click="calendarClick"></u-cell-item> -->
				<!-- <u-cell-item icon="bell" :iconStyle="iconStyle" title="消息" @click="toUrl('/pages/mine/message')"></u-cell-item>
				<u-cell-item icon="heart" :iconStyle="iconStyle" title="收藏" @click="toUrl('/pages/mine/heart')"></u-cell-item>
				<u-cell-item icon="fingerprint" :iconStyle="iconStyle" title="足迹" @click="toUrl('/pages/mine/foot')"></u-cell-item> -->
				<u-cell-item icon="file-text" :iconStyle="iconStyle" title="反馈" @click="toUrl('/pages/mine/feedback')"></u-cell-item>
				<!-- open-type="contact" 微信小程序的客服组件 -->
				
					<u-cell-item :iconStyle="iconStyle" icon="server-fill" title="地图" @click="toUrl('/pages/mine/map')"></u-cell-item>
				
			</u-cell-group>
		</view>

		<view class="u-m-t-20">
			<u-cell-group>
				<u-cell-item icon="setting" :iconStyle="iconStyle" title="设置" @click="toUrl('/pages/mine/setting')"></u-cell-item>
			</u-cell-group>
		</view>
		<!-- 签到弹窗 -->
		<u-popup v-model="show" borderRadius="20" mode="center" length="50%">
			<view class="pupbox">
				<view class="box-icon u-flex u-row-center">
					<view><u-icon name="gift-fill" size="158" color="#F05C52"></u-icon></view>
				</view>
				<view class="text-center red">签到成功,奖励10积分</view>
			</view>
		</u-popup>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				imgAddress:"",
				name:"游客",
				stuNumber:"",
				logined:true,
				user4:{
					name:"游客",
					stuNumber:"请点击登录账号",
					pwd:""
				},
				background: {
					'background-image': 'linear-gradient(45deg, #2BC3C8, #84E7B9)'
				},
				iconStyle:{color:'#2BC3C8'},
				customStyle:{borderRadius:'88rpx'},
				show: false,
				disabled: false
			}
		},
		onLoad() {
			
		},
		onShow(){
			try{
				//1.获取用户信息
				//2.不存在显示使logined为false.
				const va1=uni.getStorageSync('shu01')
				const value=uni.getStorageSync('wen')
				console.log("aaa")
				console.log(va1)
				console.log(value)
				if(value=="1"&&va1!="12"){
					console.log("bbb")
					const value1=uni.getStorageSync('user1')
					this.name=value1.name
					this.stuNumber=value1.stuNumber
					console.log(this.name)
					console.log(this.stuNumber)
					this.logined=false
					this.imgAddress=value1.imgAddress;
				}
				else if(value=="2"&&va1!="12"){
					const value2=uni.getStorageSync('admin')
					this.name=value2.name
					this.stuNumber=value2.id
					this.logined=false
					this.imgAddress=value2.imgAddress;
				}else{
					this.name="游客"
					this.stuNumber=""
					this.logined=true
				}
				console.log(value);
				console.log("我来了")
			}catch(e){
				//TODO handle the exception
				console.log("出现异常");
			}
		},
		methods: {
			goSelectheadpic(){				uni.navigateTo({					url:'/pages/mine/headchange'				})
			},
			denglu(){
				if(this.logined){
					uni.navigateTo({
						url:"/pages/login/login"
					})
				}else{
					this.$u.toast("请先在设置退出账号，再登录其他账号")
					console.log(this.logined)
				}
			},
			calendarClick() {
				this.show = !this.show
			},
			toUrl(url) {
				this.$common.navigateTo(url)
			},
			// 扫码不支持H5
			scan() {
				// #ifdef H5
				this.$common.errorToShow('H5不支持扫码');
				// #endif
				// #ifdef APP-PLUS || MP
				uni.scanCode({
					success: function(res) {
						console.log('条码类型：' + res.scanType);
						console.log('条码内容：' + res.result);
					}
				});
				// #endif
			},
		}
	}
</script>

<style lang="scss" scoped>
	page {
		background-color: #ededed;
	}

	.pupbox {
		height: 320rpx;
		background-color: #84E7B9;
		.box-icon{
			padding: 60rpx 30rpx 10rpx;
		}
	}

	.camera {
		width: 54px;
		height: 44px;

		&:active {
			background-color: #ededed;
		}
	}

	.user-box {
		background-color: #fff;
	}

	.class-none {
		border: none;
		margin: 0;
		padding: 0;
		background: #FFFFFF;
		outline: none;
	}

	.class-none::after {
		outline: none;
		border: none;
	}
	
	.red{
		color: #FF0F00;
	}
</style>
